package com.shadow.study.java.base.dy.study1;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
public class PayService {

    @Resource
    List<IPay> payList;

    @GetMapping("pay/{code}")
    public void pay(@PathVariable("code") final String code) {
        for (IPay pay : payList) {
            if (pay.supports(code)) {
                pay.pay();
            }
        }
    }
}
